package com.github.eclipseace.mybatis.crud;

import java.util.Collection;
import java.util.List;

import com.github.eclipseace.mybatis.entity.mapper.ApplyStatement;
import com.github.eclipseace.mybatis.pagination.PageList;
import com.github.eclipseace.mybatis.pagination.PageRowBounds;

/**
 * @author eclipseAce
 * @param <ID>
 * @param <E>
 */
public interface CrudMapper<ID, E> {
	@ApplyStatement("select")
	E select(ID id);

	@ApplyStatement("selectBatch")
	List<E> selectBatch(Collection<? extends ID> ids);

	@ApplyStatement("selectBatch")
	PageList<E> selectBatch(Collection<? extends ID> ids, PageRowBounds rowBounds);

	@ApplyStatement("selectAll")
	List<E> selectAll();

	@ApplyStatement("selectAll")
	PageList<E> selectAll(PageRowBounds rowBounds);

	@ApplyStatement("selectExample")
	List<E> selectExample(Example<E> example);

	@ApplyStatement("selectExample")
	PageList<E> selectExample(Example<E> example, PageRowBounds rowBounds);

	@ApplyStatement("exists")
	boolean exists(ID id);

	@ApplyStatement("existsExample")
	boolean existsExample(Example<E> example);

	@ApplyStatement("countAll")
	long countAll();

	@ApplyStatement("countExample")
	long countExample(Example<E> example);

	@ApplyStatement("insert")
	int insert(E entity);

	@ApplyStatement("insertBatch")
	int insertBatch(Collection<? extends E> entities);

	@ApplyStatement("update")
	int update(ID id, E entity);

	@ApplyStatement("updateAll")
	int updateAll(E entity);

	@ApplyStatement("updateBatch")
	int updateBatch(Collection<? extends ID> ids, E entity);

	@ApplyStatement("updateExample")
	int updateExample(Example<E> example, E entity);

	@ApplyStatement("delete")
	int delete(ID id);

	@ApplyStatement("deleteBatch")
	int deleteBatch(Collection<? extends ID> ids);

	@ApplyStatement("deleteAll")
	int deleteAll();

	@ApplyStatement("deleteExample")
	int deleteExample(Example<E> example);
}
